package com.qckj.amz.controller;

import com.qckj.amz.domain.ConfigInfringingWord;
import com.qckj.amz.service.IConfigInfringingWordService;
import com.qckj.common.annotation.Log;
import com.qckj.common.core.controller.BaseController;
import com.qckj.common.core.domain.AjaxResult;
import com.qckj.common.core.page.TableDataInfo;
import com.qckj.common.enums.BusinessType;
import com.qckj.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 侵权词维护Controller
 *
 * @author luchuan
 * @since 1.0 2022-04-23
 */
@RestController
@RequestMapping("/amz/configInfringingWord")
public class ConfigInfringingWordController extends BaseController {
    @Autowired
    private IConfigInfringingWordService configInfringingWordService;

    /**
     * 查询侵权词维护列表
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConfigInfringingWord configInfringingWord) {
        Page<ConfigInfringingWord> page = configInfringingWordService.findConfigInfringingWordPage(configInfringingWord);
        return getDataTable(page);
    }

    /**
     * 导出侵权词维护列表
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:export')")
    @Log(title = "侵权词维护", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ConfigInfringingWord configInfringingWord) {
        List<ConfigInfringingWord> list = configInfringingWordService.findConfigInfringingWordList(configInfringingWord);
        ExcelUtil<ConfigInfringingWord> util = new ExcelUtil<>(ConfigInfringingWord.class);
        return util.exportExcel(list, "configInfringingWord");
    }

    /**
     * 获取侵权词维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(configInfringingWordService.findById(id));
    }

    /**
     * 新增侵权词维护
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:add')")
    @Log(title = "侵权词维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConfigInfringingWord configInfringingWord) {
        configInfringingWordService.save(configInfringingWord);
        return AjaxResult.success();
    }

    /**
     * 修改侵权词维护
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:edit')")
    @Log(title = "侵权词维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConfigInfringingWord configInfringingWord) {
        configInfringingWordService.save(configInfringingWord);
        return AjaxResult.success();
    }

    /**
     * 删除侵权词维护
     */
    @PreAuthorize("@ss.hasPermi('amz:configInfringingWord:remove')")
    @Log(title = "侵权词维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        configInfringingWordService.deleteByIds(Arrays.asList(ids));
        return AjaxResult.success();
    }
}
